<?php get_header();wp_dequeue_script('jq-archive-script'); ?>
    <!--主内容区-->
    <div class="main-body mt-20">
        <div class="container" style="min-height: 750px;">

                <div class="pure-g act-grid">
    <!--                添加ajax内容-->
                </div>

                <div class="spinner">
                    <div class="rect1"></div>
                    <div class="rect2"></div>
                    <div class="rect3"></div>
                    <div class="rect4"></div>
                    <div class="rect5"></div>
                </div>

                <p class="under-line"> - 别扯了，我们也是有底线的 - </p>

        </div>
    </div>


    <!--components-->
    <link rel='stylesheet' id='build-css'  href='<?php echo site_url(); ?>/wp-content/themes/jiangqie/css/purecss.css?ver=5.6' type='text/css' media='all' />
    <link rel='stylesheet' id='build-css'  href='<?php echo site_url(); ?>/wp-content/themes/jiangqie/css/build.css?ver=5.6' type='text/css' media='all' />

    <script type="text/javascript">
        var $ = jQuery.noConflict();//解除wordpress jquery限制
        var start = 0;
        var loadable = true;

        $(".spinner").show();
        $(".under-line").hide();
        $(document).ready(function () {
            load_fpv();
        });

        //滑动到底部加载
        // scroll event
        $(window).scroll(function(){
            // scroll at bottom
            at_bottom_ajax();
        });

        function at_bottom_ajax() {
            //滚动条所在位置的高度
            totalheight = parseFloat($(window).height()) + parseFloat($(window).scrollTop());
            //当前文档高度   小于或等于   滚动条所在位置高度  则是页面底部
            if(($(document).height()) <= totalheight+300) {
                load_fpv();
            }
        }

        function load_fpv() {
            if(!loadable){
                console.log("不要着急，慢慢来")
                return false;
            }
            loadable = false;//同一时间只能一个在执行
            $(".spinner").show();
            $.post("/wp-admin/admin-ajax.php", {
                action: 'ajax_more_fpv',
                start: start
            }, function (data, status) {
                if(data.length > 0){
                    $(".spinner").hide();
                    $(".under-line").hide();
                    start += 1;
                    for (var i=0;i<data.length;i++) {
                        html = '<div class="pure-sm-1 pure-u-md-1-2 pure-u-lg-1-3 pure-u-xl-1-4 grid-item">' +
                            '<div class="grid-image nl-image" data-background="'+data[i].thumbnail+'">' +
                            '<a href="'+data[i].link+'" class="grid-link"><span class="act-title">'+data[i].title+'</span>' +
                            // '<div class="act-user">by OptimaZe</div>' +
                            '</a>' +
                            '</div>' +

                            '<div class="act-footer-left act-age">'+data[i].time+'</div>' +
                            '<div class="act-footer">' +
                            '<a href="#">浏览<cite>'+data[i].view+'</cite>·</a>' +
                            '<a href="#">点赞<cite>'+data[i].thumbup+'</cite></a>' +
                            '</div>' +
                            '</div>' +
                            '</div>';
                        $(".act-grid").append(html);
                    }
                    // $(".act-grid").append('<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"><\/script><ins class="adsbygoogle"style="display:block;height:200px;width:100%;text-align:center;"data-ad-client="ca-pub-6243451787655828"data-ad-slot="3375266862"data-ad-format="auto"data-full-width-responsive="true"></ins><script>(adsbygoogle = window.adsbygoogle || []).push({});<\/script>');
                    nlazy();
                    if(data.length < 12){
                        $(".under-line").show();
                        loadable = false;

                    }else{
                        loadable = true;

                        totalheight = parseFloat($(window).height()) + parseFloat($(window).scrollTop());
                        console.log("滚动条高度：" + totalheight);
                        console.log("文档高度：" + $(document).height())
                        if(totalheight == $(document).height()){
                            load_fpv();
                        }
                    }
                }else{
                    $(".spinner").hide();
                    $(".under-line").show();
                    loadable = false;
                }

            });
        }

    </script>
    <!--nolazy.js-->
    <script type='text/javascript' src='<?php echo site_url(); ?>/wp-content/themes/jiangqie/js/nLazy.js?ver=0.3'></script>

<?php get_footer(); ?>